<div class="sign-in">
	<em>Login: </em><input type="text" name="login" id="login"
		placeholder="Login"> <em>Password: </em><input type="password"
		name="password" id="password" placeholder="Password">
	<div id="sign-in" class="button" onclick="submitLogin();">
		<span>Go!</span>
	</div>
</div>
<script>
	!function() {
		$('#login').focus();
		$('.sign-in').draggable();
		$('#login').attr('value', $.cookie('uid'));
		$('input[name=login],input[name=password]').keyup(function(event) {
			if (event.keyCode == 13) {
				submitLogin();
			}
		});
	}()
	function submitLogin() {
		if ($('#login').val() == '' || $('#password').val() == '') {
			$('#login').attr('required', 'required');
			$('#password').attr('required', 'required');
			return;
		}
		$.cookie('uid', $('#login').val());
		$.ajax({
			url : '/s/?action=login',
			data : 'login=' + $('#login').val() + '&password=' + $('#password').val(),
			success : function(resp) {
				if (resp.success === true) {
					$.cookie('uid', $('#login').val(), {
						expires : 365,
						path : '/'
					});
					window.location.reload();
				} else {
					$('.sign-in').append('<em style=\'color:red;\'>' + resp.err + '</em>');
					$('#login').attr('required', 'required');
					$('#password').attr('required', 'required');
					return;
				}
			}
		});
	}
</script>